#include <iostream>
#include <map>
#include <cmath>

using namespace std;

map<string, int> words = {
    {"zero", 0},
    {"one", 1},
    {"two", 2},
    {"three", 3},
    {"four", 4},
    {"five", 5},
    {"six", 6},
    {"seven", 7},
    {"eight", 8},
    {"nine", 9}
};

bool isPrime(int n) {
    if (n <= 1) {
        return false;
    }
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    string word1, word2, word3;
    cin >> word1 >> word2 >> word3;

    if (words.find(word1) == words.end() || words.find(word2) == words.end() || words.find(word3) == words.end()) {
        cout << "wrong input" << endl;
        return 0;
    }

    int number = words[word1] * 100 + words[word2] * 10 + words[word3];
    if (number < 100 || number > 999) {
        cout << "wrong input" << endl;
        return 0;
    }
    int prime = number;
    while (!isPrime(prime)) {
        prime++;
    }

    cout << prime << endl;

    return 0;
}
